﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class ModifierDossierArchiveForm : Form
    {

        private Dossier_Archive dossierArchive = new Dossier_Archive();
        public Dossier_Archive Dossier
        {
            get ;
            set ; 
        }

        
        public RechercheDossierArchiveForm recherchedossierArchive { get; set; }
        public ModifierDossierArchiveForm()

  
        {
            InitializeComponent();
            RAMEDEntities1 context = SingletonContext.GetContext();
            comboBoxannexe.DataSource = context.Annexe_administratif;
            comboBoxannexe.DisplayMember = "nom_annexe_administratif";
            comboBoxannexe.ValueMember = "id_annexe_administratif"; 
        }

        public void InitialiserChamps()
        {

            txtprenom.Text = Dossier.Prénom;
            txtnom.Text = Dossier.Nom;
            txtnumdossier.Text = Dossier.Num_Dossier;
            txtcin.Text = Dossier.CIN;
            comboBoxannexe.SelectedValue = Dossier.id_annexe_administratif;
            dateTimeArchive.Value = Dossier.date_archive.Value;

        }

        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            RAMEDEntities1 Context = SingletonContext.GetContext();

            Dossier.Prénom = txtprenom.Text;
            Dossier.Nom = txtnom.Text;
            Dossier.Num_Dossier = txtnumdossier.Text;
            Dossier.CIN = txtcin.Text;
            Dossier.date_archive = dateTimeArchive.Value;
            Dossier.Annexe_administratif = (Annexe_administratif)comboBoxannexe.SelectedItem;
            recherchedossierArchive.mettreAjourFormGridView();
            Context.SaveChanges();
            this.Dispose();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        
    }
}
